package com.tedu.ourprojct.controller;

import com.tedu.ourprojct.mapper.OlderMapper;
import com.tedu.ourprojct.pojo.dto.OlderDTO;
import com.tedu.ourprojct.pojo.entity.Older;
import com.tedu.ourprojct.pojo.vo.OlderAdminVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * 健康管理类的增、删、改、查
 *
 * @author 程辉
 */
@RestController
@RequestMapping("/older")
public class OlderController {
    @Autowired
    OlderMapper mapper;
    @RequestMapping("/select")
    public List<OlderAdminVO> selectAdmin(){
        return mapper.selectAdmin();
    }

    @RequestMapping("/insert")
    public void insert(@RequestBody OlderDTO olderDTO){
        Older older = new Older();
        BeanUtils.copyProperties(olderDTO,older);
        older.setBgTime(new Date());
        older.setBlTime(new Date());
        older.setBpTime(new Date());
        older.setCreated(new Date());
        older.setBirth(new Date());
        mapper.insert(older);
    }
}
